package com.jungle.mvvm.sample.ui.coin;

import android.databinding.Observable;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.ViewGroup;

import com.jungle.mvvm.base.BaseFragment;
import com.jungle.mvvm.sample.BR;
import com.jungle.mvvm.sample.R;
import com.jungle.mvvm.sample.databinding.FragmentCoinBinding;


/**
 * @ClassName CollectActivity
 * @Description 收藏页面
 * @Author Daniel
 * @Version V1.0.0
 */
public class CoinFragment extends BaseFragment<FragmentCoinBinding, CoinViewModel> {
    @Override
    public int initContentView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        return R.layout.fragment_coin;
    }

    @Override
    public int initVariableId() {
        return BR.viewModel;
    }

    @Override
    public void initViewObservable() {
        viewModel.uc.finishRefreshing.addOnPropertyChangedCallback(new Observable.OnPropertyChangedCallback() {
            @Override
            public void onPropertyChanged(Observable observable, int i) {
                binding.twinklingRefreshLayout.finishRefreshing();
            }
        });
        viewModel.uc.finishLoadmore.addOnPropertyChangedCallback(new Observable.OnPropertyChangedCallback() {
            @Override
            public void onPropertyChanged(Observable observable, int i) {
                binding.twinklingRefreshLayout.finishLoadmore();
            }
        });
    }

    @Override
    public void initData() {
        viewModel.initData();
    }
}
